<%@page import="com.cbts.util.MD5Util"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String errMsg=null;
	if(request.getAttribute("error")!=null){
		errMsg = request.getAttribute("error").toString(); 
	}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		
		<title>公司差旅系统登录</title>
		<link href="css/style.css" rel="stylesheet" type="text/css">
		<!--
		<link rel="stylesheet" type="text/css" href="styles.css">
		-->
		<script src="js/jquery-1.9.1.min.js"></script>
		<script src="js/jquery.validate.min.js"></script>
	</head>
	<body>
		<div id="login_header">
			<div id="logo">
				<img src="images/logo-1.png">
			</div>
		</div>
		<div id="login_main">
			<div id="login_left">
				<img src="images/img1.jpg"  width="100%">
			</div>
			<div id="login_right">
				<form action="userInfoAction!login.action" method="post" class="loginForm">
					<div class="login_m">
						<div class="login_boder">
							<div class="login_padding">
								<h2>
									账&nbsp;&nbsp;&nbsp;&nbsp;号
								</h2>
								<label>
									<input type="text" name ="userInfo.userid" id="userid" class="txt_input txt_input2"
										placeholder="账号">
								</label>
								<br/>
								<h2>
									密&nbsp;&nbsp;&nbsp;&nbsp;码
								</h2>
								<label>
									<input type="password" name="userInfo.pwd" id="userpwd"
										class="txt_input" placeholder="密码">
								</label>
								<br/>
								<h2>
									验证码
								</h2>
								<label>
									<input type="text" name="codeinput" id="codeinput"
										class="txt_input" placeholder="验证码">
									<img id="code" src="gif.jsp"><a href="javascript:changeimg()">换一张 </a><br>
								</label>
								<span class="extract">
								<a href="javascript:void(0);" onclick="forget()">忘记密码?</a>
								</span>
								<div class="rem_sub">
									<label>
									
										<input type="submit" class="sub_button" name="button"
											id="button" value="登录"  style="opacity: 0.7;">
									</label>
								</div>
							</div>
						</div>
						<!--login_boder end-->
					</div>
					<!--login_m end-->
				</form>
				<div id="messageBox"></div>
			</div>
		</div>
		<div id="login_footer">
			<div id="footer_message">
				公司差旅管理系统&copy软卓小分队
			</div>
		</div>
		<script>
		//换验证码
			function changeimg()
			{
			
				var myimg = document.getElementById("code"); 
				now = new Date(); 
				myimg.src="gif.jsp?code="+now.getTime();
			} 
		
		function forget(){
			var userid = document.getElementById("userid").value;
			
			if(userid==''){
				alert("请填写账户（员工号）");
				return;
			}
			
		$.ajax( {
			url: "forgetPWD.action",
			type: "get",
			data: {"forgetUserid": userid},	//获取li的属性？可以传递的
			success: function(sendResult){
				alert(sendResult);
			},
			error: function(){
				alert("fail");
			}
	   });
	}
	
			$(".loginForm").validate({
				rules:{  
				   "userInfo.userid":{  
				        required: true,  
				        minlength: 2,  
				        maxlength: 15  
				    },  
				   "userInfo.pwd" :{  
				        required: true,  
				        minlength: 6,
				        maxlength:15  
				    }
				},  
				messages:{  
				    "userInfo.userid":{  
				        required: "请填写账号",  
				        minlength: "账号长度不能小于2个字符",  
				        maxlength: "账号长度不能大于15个字符"  
				    },  
				    "userInfo.pwd" :{  
				        required: "请填写密码",  
				        minlength: "密码长度不能小于6个字符",
				        maxlength: "密码长度不能大于15个字符"  
				    }
				}  
			});
			
			var errMsg = "<%=errMsg%>";
			if(errMsg!="null"){
				alert(errMsg);
			}
			
		</script>
		
	</body>
</html>
